#include "aky_com_include.h"

void aky_sdadc_init(void)
{
	VREG = 0xdc;	
	AMPM = 0x23;	
	ADCM1= 0x66;	
	ADCM2= 0x18;	
	CHS	 = 0x3C;	
	OPM	 = 0x00;		
	ADCM1 |= 0x01;						//Enable ADC
    SDADC_POWER_PROT_REG |= SDADC_POWER_PIN; // IO端口方向
    SDADC_POWER_UP_REG &= ~SDADC_POWER_PIN;  // 上拉配置
    SDADC_POWER_ON;

#if (AKY_DEBUG_UART_PRINTF == 1)
    aky_uart_send_string("aky_sdadc_init\n");
#endif
}


uint16_t aky_get_sdadc_val(void)
{
    uint32_t res;
	res = (ADCDH << 8)| ADCDM;
    return (uint16_t)res;
}


void get_sdadc_val_pro(void)
{
    static uint8_t time_cnt;
    time_cnt++;
    if(time_cnt >= 20  / AKY_TICK_INTERVAL)
    {
        time_cnt = 0;
        SensorCountw = aky_get_sdadc_val();
        flag_adc_ok = 1;
    }
}
